package com.mukefile.service.impl;

import com.mukefile.dao.ActualFileDao;
import com.mukefile.dao.UserFileDao;
import com.mukefile.dto.DownloadFileDto;
import com.mukefile.pojo.ActualFile;
import com.mukefile.pojo.UserFile;
import com.mukefile.service.DownloadService;
import com.mukefile.service.SysProfileService;
import com.mukefile.utils.constant.Constant;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author xinke.huang@hand-china.com
 * @version 1.0
 * @date 2021/2/12
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DownloadServiceImpl implements DownloadService {
    @Resource
    ActualFileDao actualFileDao;
    @Resource
    UserFileDao userFileDao;
    @Resource
    SysProfileService sysProfileService;
    @Override
    public String getActualPath(DownloadFileDto dto) {
        UserFile userFile = userFileDao.selectUserFileById(dto.getId());
        ActualFile actualFile = actualFileDao.getActualFileById(userFile.getActualId());
        String actualPath = sysProfileService.getSysProfileValue(Constant.ACTUAL_PATH);
        return actualPath+actualFile.getFilename();
    }
}
